package dlg.code;

import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        A a = new A();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();
        new Thread(a).start();

//        new ThreadPoolExecutor()
    }

    static class A implements Runnable{
        private int t = 1000;

        @Override
        public void run() {
            while (true) {
                try {
                    TimeUnit.MILLISECONDS.sleep(new Random().nextInt(100));
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

                System.out.println("t = " + t--);
                if (t <= 0) {
                    break;
                }
            }
        }
    }
}
